home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Linux Cubed Series 7: Sunsite
/
Linux Cubed Series 7 - Sunsite Vol 1.iso
/
system
/
emulator
/
bsvc-1.000
/
bsvc-1
/
bsvc-1.0.4
/
samples
/
Motorola68000
/
MatrixMultiply.LIS
< prev
next >
Wrap
File List
|
1995-07-26
|
71KB
|
1,021 lines
00000000 1 *
00000000 2 * Interactive Matrix Multiply program for the Motorola 68000
00000000 3 *
00000000 4
00001000 5 ORG $1000
00001000 6
00001000 =00EFFC01 7 DUART EQU $effc01
00001000 =00000000 8 MR1A EQU 0
00001000 =00000000 9 MR2A EQU 0
00001000 =00000002 10 SRA EQU 2
00001000 =00000004 11 CRA EQU 4
00001000 =00000002 12 CSRA EQU 2
00001000 =00000006 13 TBA EQU 6
00001000 =00000006 14 RBA EQU 6
00001000 =0000000A 15 IMR EQU 10
00001000 =00000016 16 TBB EQU $16
00001000 =00000014 17 CRB EQU $14
00001000 =00000010 18 MR1B EQU $10
00001000 =00000010 19 MR2B EQU $10
00001000 =00000012 20 SRB EQU $12
00001000 21
00001000 43F9 00EFFC01 22 LEA DUART,A1
00001006 137C 0010 0004 23 MOVE.B #%00010000,CRA(A1) Reset MR?A pointer
0000100C 137C 0023 0000 24 MOVE.B #%00100011,MR1A(A1) 8 data bits
00001012 137C 0017 0000 25 MOVE.B #%00010111,MR2A(A1) Normal Mode
00001018 137C 00BB 0002 26 MOVE.B #%10111011,CSRA(A1) Set clock to 9600
0000101E 137C 0005 0004 27 MOVE.B #%00000101,CRA(A1) Enable Rx and Tx
00001024 28
00001024 2E7C 00004000 29 MOVE.L #$4000,A7 Setup the stack pointer
0000102A 30
0000102A 4EB9 00001C00 31 MAIN: JSR CLEAR
00001030 4EB9 00001518 32 JSR TITLE
00001036 33
00001036 4EB9 00001C00 34 JSR CLEAR
0000103C 35
0000103C 4EB9 00001CB6 36 JSR GETSIZE
00001042 37
00001042 3239 000010D6 38 MOVE.W MA_C,D1
00001048 3039 000010D4 39 MOVE.W MA_R,D0
0000104E 207C 000010DC 40 MOVE.L #MA_DAT,A0
00001054 227C 000013FC 41 MOVE.L #MA_TI,A1
0000105A 4EB9 000021AA 42 JSR MATIN
00001060 43
00001060 3239 000010DA 44 MOVE.W MB_C,D1
00001066 3039 000010D8 45 MOVE.W MB_R,D0
0000106C 207C 000011A4 46 MOVE.L #MB_DAT,A0
00001072 227C 0000140C 47 MOVE.L #MB_TI,A1
00001078 4EB9 000021AA 48 JSR MATIN
0000107E 49
0000107E 3039 000010D4 50 MOVE.W MA_R,D0
00001084 3239 000010D6 51 MOVE.W MA_C,D1
0000108A 3439 000010D8 52 MOVE.W MB_R,D2
00001090 3639 000010DA 53 MOVE.W MB_C,D3
00001096 207C 000010DC 54 MOVE.L #MA_DAT,A0
0000109C 227C 000011A4 55 MOVE.L #MB_DAT,A1
000010A2 247C 0000126C 56 MOVE.L #MC_DAT,A2
000010A8 4EB9 00001F24 57 JSR MATMULT
000010AE 58
000010AE 3039 000010D4 59 MOVE.W MA_R,D0
000010B4 3239 000010DA 60 MOVE.W MB_C,D1
000010BA 207C 0000126C 61 MOVE.L #MC_DAT,A0
000010C0 227C 0000141C 62 MOVE.L #MC_TI,A1
000010C6 4EB9 00001FA2 63 JSR MATOUT
000010CC 64
000010CC 4EF9 00002468 65 JMP EXIT
000010D2 4E71 66 NOP
000010D4 67
000010D4 68 MA_R: DS.W 1
000010D6 69 MA_C: DS.W 1
000010D8 70 MB_R: DS.W 1
000010DA 71 MB_C: DS.W 1
000010DC 72 MA_DAT: DS.W 100 Matrix A Data
000011A4 73 MB_DAT: DS.W 100 Matrix B Data
0000126C 74 MC_DAT: DS.L 100 Matrix C Data (Result)
000013FC 45 6E 74 65 72 20 4D 61 74 ... 75 MA_TI: DC.B 'Enter Matrix A',0,0
0000140C 45 6E 74 65 72 20 4D 61 74 ... 76 MB_TI: DC.B 'Enter Matrix B',0,0
0000141C 52 65 73 75 6C 74 69 6E 67 ... 77 MC_TI: DC.B 'Resulting Matrix C',0,0
00001430 78
00001430 79 *
00001430 80 * Input a string
00001430 81 *
00001430 82
00001430 48E7 FFFE 83 INPUT: MOVEM.L A0-A6/D0-D7,-(A7)
00001434 84
00001434 2A48 85 MOVE.L A0,A5 Save buffer address
00001436 2C49 86 MOVE.L A1,A6 Save valid string address
00001438 2E00 87 MOVE.L D0,D7 Save Max length
0000143A 7200 88 MOVE.L #0,D1 Current string length
0000143C 89
0000143C 4EB9 000014F0 90 IN_LOOP: JSR GETC Get a character
00001442 91
00001442 0C00 0008 92 CMPI.B #$08,D0 Is it backspace
00001446 6700 0046 93 BEQ IN_BS
0000144A 94
0000144A 0C00 000D 95 CMPI.B #$0D,D0 Is it return
0000144E 6700 0074 96 BEQ IN_RET
00001452 97
00001452 98 * Make sure it's a valid character
00001452 204E 99 MOVE.L A6,A0
00001454 0C10 0000 100 IN_VL: CMPI.B #0,(A0) End of valid string?
00001458 6700 000A 101 BEQ IN_INVALID
0000145C 102
0000145C B018 103 CMP.B (A0)+,D0 Is it a valid char?
0000145E 6700 000E 104 BEQ IN_VALID
00001462 105
00001462 60F0 106 BRA IN_VL Loop
00001464 107
00001464 4EB9 00001BF4 108 IN_INVALID: JSR BELL Sound Bell
0000146A 4EF8 143C 109 JMP IN_LOOP Get another character
0000146E 110
0000146E B247 111 IN_VALID: CMP.W D7,D1 Have we reach max lenght?
00001470 6600 000C 112 BNE IN_VA2 NO!
00001474 113
00001474 4EB9 00001BF4 114 JSR BELL
0000147A 4EF8 143C 115 JMP IN_LOOP
0000147E 116
0000147E 1B80 1000 117 IN_VA2: MOVE.B D0,0(A5,D1) Save character in buffer
00001482 5241 118 ADDI.W #1,D1 Inc Lenght counter
00001484 4EB9 000014D0 119 JSR PUTC Output character to screen
0000148A 120
0000148A 4EF8 143C 121 JMP IN_LOOP
0000148E 122
0000148E 123
0000148E 0C41 0000 124 IN_BS: CMPI.W #0,D1 Make sure no wrap around
00001492 6600 000C 125 BNE IN_BOK
00001496 126
00001496 4EB9 00001BF4 127 JSR BELL
0000149C 4EF8 143C 128 JMP IN_LOOP
000014A0 129
000014A0 103C 0008 130 IN_BOK: MOVE.B #$08,D0 BackSpace on screen
000014A4 4EB9 000014D0 131 JSR PUTC
000014AA 103C 0020 132 MOVE.B #$20,D0
000014AE 4EB9 000014D0 133 JSR PUTC
000014B4 103C 0008 134 MOVE.B #$08,D0
000014B8 4EB9 000014D0 135 JSR PUTC
000014BE 136
000014BE 5341 137 SUBI.W #1,D1 Dec length counter
000014C0 4EF8 143C 138 JMP IN_LOOP
000014C4 139
000014C4 140
000014C4 1BBC 0000 1000 141 IN_RET: MOVE.B #0,0(A5,D1) Null Terminate
000014CA 142
000014CA 4CDF 7FFF 143 MOVEM.L (A7)+,A0-A6/D0-D7 Restore REGS
000014CE 144
000014CE 4E75 145 RTS
000014D0 146 *
000014D0 147 * Routines for performing Polled I/O At the Console Serial Port
000014D0 148 *
000014D0 149 * By: Bradford W. Mott
000014D0 150 *
000014D0 151
000014D0 =0000000A 152 LINEFEED: EQU 10 * LineFeed Character value
000014D0 =0000000D 153 CARR_RETURN: EQU 13 * Carrage Return character value
000014D0 154
000014D0 155 *
000014D0 156 * The character in D0 is transmitted to the CONSOLE ACIA.
000014D0 157 * The newline character <LF> is expanded into <LF>/<CR>.
000014D0 158 *
000014D0 159
000014D0 0839 0002 00EFFC03 160 PUTC: BTST #2,SRA+DUART * Test Transmit data register empty
000014D8 67F6 161 BEQ.S PUTC * If not keep polling
000014DA 13C0 00EFFC07 162 MOVE.B D0,TBA+DUART * Transmit the character
000014E0 B03C 000A 163 CMP.B #LINEFEED,D0 * Check for LINEFEED
000014E4 6600 0008 164 BNE PUTEXT
000014E8 103C 000D 165 MOVE.B #CARR_RETURN,D0 * Load CR into D0
000014EC 60E2 166 BRA PUTC * Output CR
000014EE 4E75 167 PUTEXT: RTS * Return to calling procedure
000014F0 168
000014F0 169
000014F0 170 *
000014F0 171 * Get a character from the CONSOLE ACIA and return it in D0
000014F0 172 *
000014F0 173
000014F0 0839 0000 00EFFC03 174 GETC: BTST #0,SRA+DUART * Test Receive data register full
000014F8 67F6 175 BEQ.S GETC * If not keep polling
000014FA 1039 00EFFC07 176 MOVE.B RBA+DUART,D0 * Read the character
00001500 4E75 177 RTS
00001502 178
00001502 2F00 179 PRINT: MOVE.L D0,-(A7) *SAVE CURRENT REGS TO STACK
00001504 1018 180 PRLOOP: MOVE.B (A0)+,D0 *GET A CHARACTER
00001506 B03C 0000 181 CMP.B #$00,D0 *IS IT A NULL CHARACTER?
0000150A 6700 0008 182 BEQ PRNTEND *IF SO, THEN YOU'RE DONE
0000150E 4EB8 14D0 183 JSR PUTC *IF NOT, THEN SEND CHARACTER TO SCREEN
00001512 60F0 184 BRA PRLOOP *LOOP UNTIL DONE
00001514 201F 185 PRNTEND: MOVE.L (A7)+,D0 *RESTORE REGS
00001516 4E75 186 RTS
00001518 187
00001518 188
00001518 207C 00001538 189 TITLE: MOVE.L #SCREEN,A0 *INITIALIZE SCREEN DATA POINTER
0000151E 4EB8 1502 190 TILP: JSR PRINT *PRINT DATA TO SCREEN
00001522 0C10 003D 191 CMPI.B #$3D,(A0) *END OF SCREEN DATA?
00001526 66F6 192 BNE TILP *IF NOT THEN KEEP PRINTING DATA
00001528 4EB8 14F0 193 TILP1: JSR GETC *IF FINISHED, GET A KEY SRIKE
0000152C 0C00 000D 194 CMPI.B #$0D,D0 *IS IT THE RETURN KEY?
00001530 66F6 195 BNE TILP1 *IF NOT THEN TRY AGAIN
00001532 4EB8 1502 196 JSR PRINT *IF SO, THEN PRINT CLEAR SCREEN CHARACTERS
00001536 4E75 197 RTS *RETURN TO MAIN
00001538 198
00001538 1B 5B 32 4A 199 SCREEN: DC.B $1B,'[2J'
0000153C 2A 2A 2A 2A 08 08 08 08 1B ... 200 DC.B '****',$08,$08,$08,$08,$1B,'[4h'
00001548 20 20 20 20 20 20 20 20 20 ... 201 DC.B ' ****',$1B,'[4l',$1B,'E'
0000159A 2A 2A 08 08 1B 5B 34 68 202 DC.B '**',$08,$08,$1B,'[4h'
000015A2 20 20 20 20 20 20 20 20 20 ... 203 DC.B ' **',$1B,'[4l',$1B,'E'
000015F6 2A 20 2A 08 08 08 1B 5B 34 68 204 DC.B '* *',$08,$08,$08,$1B,'[4h'
00001600 20 20 20 20 20 20 20 20 20 ... 205 DC.B ' * *',$1B,'[4l',$1B,'E'
00001653 2A 08 1B 5B 34 68 206 DC.B '*',$08,$1B,'[4h'
00001659 20 20 20 20 20 20 20 20 20 ... 207 DC.B ' *',$1B,'[4l',$1B,'E',$1B,'E'
000016B0 20 20 20 20 20 20 20 20 20 ... 208 DC.B ' M M A TTTTT RRRR III X X',$1B,'E'
000016EB 20 20 20 20 20 20 20 20 20 ... 209 DC.B ' MM MM A A T R R I X X ',$1B,'E'
00001726 20 20 20 20 20 20 20 20 20 ... 210 DC.B ' M M M A A T R R I X ',$1B,'E'
00001761 20 20 20 20 20 20 20 20 20 ... 211 DC.B ' M M AAAAA T RRRR I X X ',$1B,'E'
0000179C 20 20 20 20 20 20 20 20 20 ... 212 DC.B ' M M A A T R R I X X',$1B,'E'
000017D7 20 20 20 20 20 20 20 20 20 ... 213 DC.B ' M M A A T R R III X X',$1B,'E'
00001812 1B 45 214 DC.B $1B,'E'
00001814 20 20 20 20 20 20 20 20 20 ... 215 DC.B ' M M U U L TTTTT III PPPP L Y Y',$1B,'E'
00001855 20 20 20 20 20 20 20 20 20 ... 216 DC.B ' MM MM U U L T I P P L Y Y',$1B,'E'
00001896 20 20 20 20 20 20 20 20 20 ... 217 DC.B ' M M M U U L T I P P L Y Y ',$1B,'E'
000018D7 20 20 20 20 20 20 20 20 20 ... 218 DC.B ' M M U U L T I PPPP L Y ',$1B,'E'
00001918 20 20 20 20 20 20 20 20 20 ... 219 DC.B ' M M U U L T I P L Y ',$1B,'E'
00001959 20 20 20 20 20 20 20 20 20 ... 220 DC.B ' M M UUU LLLLL T III P LLLLL Y ',$1B,'E'
0000199A 1B 45 221 DC.B $1B,'E'
0000199C 2A 08 1B 5B 34 68 222 DC.B '*',$08,$1B,'[4h'
000019A2 20 20 20 20 20 20 20 20 20 ... 223 DC.B ' *',$1B,'[4l',$1B,'E'
000019F7 2A 20 2A 08 08 08 1B 5B 34 68 224 DC.B '* *',$08,$08,$08,$1B,'[4h'
00001A01 20 20 20 20 20 20 20 20 20 ... 225 DC.B ' * *',$1B,'[4l',$1B,'E'
00001A54 2A 2A 08 08 1B 5B 34 68 226 DC.B '**',$08,$08,$1B,'[4h'
00001A5C 20 20 20 20 20 20 20 20 20 ... 227 DC.B ' **',$1B,'[4l',$1B,'E'
00001AB0 2A 2A 2A 2A 08 08 08 08 1B ... 228 DC.B '****',$08,$08,$08,$08,$1B,'[4h'
00001ABC 20 20 20 20 20 20 20 20 20 ... 229 DC.B ' ****',$1B,'[4l',$1B,'E'
00001B0E 50 72 65 73 73 20 52 45 54 ... 230 DC.B 'Press RETURN to Continue... ',$1B,'[4l',$00,$3D,$1B,'[2J',$00,$00
00001B36 231
00001B36 48E7 FFFE 232 LTOA: MOVEM.L D0-D7/A0-A6,-(A7)
00001B3A 233
00001B3A 113C 0000 234 MOVE.B #$00,-(A0) *APPEND NULL CHARACTER TO OUTPUT STRING
00001B3E 143C 0000 235 MOVE.B #$00,D2 *SET NEGATIVE FLAG TO INDICATE NON NEGATIVE NUMBER FOR NOW
00001B42 2601 236 MOVE.L D1,D3 *MOVE HEX OUTPUT (D1) TO HOLDER (D3)
00001B44 6A00 0014 237 BPL LTOALOOP *IF POSITIVE THEN GO CONVERT
00001B48 6600 000A 238 BNE LTOA2 *IF ZERO THEN YOUR FINISHED
00001B4C 239
00001B4C 113C 0030 240 MOVE.B #48,-(A0)
00001B50 6000 0026 241 BRA LTOAEND
00001B54 242
00001B54 4483 243 LTOA2: NEG.L D3 *IF NEGATIVE THEN NEGATE
00001B56 1E3C 00AA 244 MOVE.B #$AA,D7 *SET NEGATIVE FLAG
00001B5A 245
00001B5A 4EB9 00001BD6 246 LTOALOOP: JSR LDIV *GO PERFORM LONG DIV BY 10 ON HEX NUMBER
00001B60 0643 0030 247 ADD.W #$30,D3 *ADD $30 TO REMAINDER
00001B64 1103 248 MOVE.B D3,-(A0) *MOVE LSB TO ASCII CHAR STRING POINTER
00001B66 2600 249 MOVE.L D0,D3 *MOVE RECEIVED QUOTIENT TO D3 TO SEND TO LDIV AGAIN
00001B68 4A80 250 TST.L D0 *IS QUOTIENT EQUAL TO ZERO?
00001B6A 66EE 251 BNE LTOALOOP *IF NOT THEN KEEP CONVERTING
00001B6C 252
00001B6C 0C07 00AA 253 CMPI.B #$AA,D7 *WAS NEGATIVE FLAG SET?
00001B70 6600 0006 254 BNE LTOAEND *NO, GO TO THE END
00001B74 113C 002D 255 MOVE.B #$2D,-(A0) *YES, APPEND A NEGATIVE SIGN TO ASCII STRING
00001B78 256
00001B78 257
00001B78 4CDF 7FFF 258 LTOAEND: MOVEM.L (A7)+,D0-D7/A0-A6
00001B7C 4E75 259 RTS *RETURN
00001B7E 260
00001B7E 261
00001B7E 48E7 7FFE 262 ATOL: MOVEM.L D1-D7/A0-A6,-(A7) *SAVE PERTINENT REGISTERS
00001B82 183C 0000 263 MOVE.B #0,D4 *SET NEGATIVE FLAG TO OFF
00001B86 7000 264 MOVE.L #0,D0 *CLEAR RESULT REGISTER
00001B88 7200 265 MOVE.L #0,D1 *CLEAR CHARACTER HOLDER
00001B8A 266
00001B8A 1218 267 ATOLLP1: MOVE.B (A0)+,D1 *GET FIRST CHARACTER IN ASCII STRING
00001B8C 6700 002C 268 BEQ ATOLDONE *IF NULL, THEN YOU'RE FINISHED
00001B90 227C 00001BCA 269 MOVE.L #VALIDSTR,A1 *SET CHARACTER CHECK POINTER
00001B96 270
00001B96 0C11 0000 271 ATOLLP2: CMP.B #0,(A1) *CHECKED FOR ALL VALID CHARACTERS?
00001B9A 67EE 272 BEQ ATOLLP1 *IF YES, GET NEXT CHARACTER IN ASCII STRING
00001B9C B23C 002D 273 CMP.B #$2D,D1 *IS IT THE NEGATIVE SIGN?
00001BA0 6700 0012 274 BEQ SETNEG *IF YES, GO SET NEGATIVE FLAG
00001BA4 B219 275 CMP.B (A1)+,D1 *IS THE CHARACTER VALID?
00001BA6 66EE 276 BNE ATOLLP2 *IF NOT, COMPARE TO OTHER VALID CHARACTERS
00001BA8 277
00001BA8 C23C 000F 278 AND.B #$0F,D1 *MASK UPPER BITS OF ASCII CHARACTER
00001BAC C0FC 000A 279 MULU #10,D0 *BEGIN CONVERSION TO BASE 10
00001BB0 D081 280 ADD.L D1,D0 *ADD NEXT DIGIT IN STRING TO RESULT
00001BB2 60D6 281 BRA ATOLLP1 *GET NEXT CHARACTER IN ASCII STRING
00001BB4 282
00001BB4 183C 00FF 283 SETNEG: MOVE.B #$FF,D4 *SET NEGATIVE FLAG
00001BB8 60D0 284 BRA ATOLLP1 *GET NEXT CHARACTER IN ASCII STRING
00001BBA 285
00001BBA B83C 00FF 286 ATOLDONE: CMP.B #$FF,D4 *WAS IT A NEGATIVE NUMBER?
00001BBE 6600 0004 287 BNE ATOLEND *NO, SKIP TO END
00001BC2 4480 288 NEG.L D0 *YES, NEGATE THE RESULT
00001BC4 289
00001BC4 4CDF 7FFE 290 ATOLEND: MOVEM.L (A7)+,D1-D7/A0-A6 *RECALL PERTINENT REGISTERS
00001BC8 4E75 291 RTS *RETURN RESULT
00001BCA 292
00001BCA 31 32 33 34 35 36 37 38 39 ... 293 VALIDSTR: DC.B '1234567890',0,0
00001BD6 294
00001BD6 2003 295 LDIV: MOVE.L D3,D0 *STORE IN D0 FOR NOW
00001BD8 4243 296 CLR.W D3 *CLEAR LOWER WORD OF DIVIDEND
00001BDA 4843 297 SWAP D3 *MOVE UPPER WORD TO LOWER POSITION
00001BDC 4840 298 SWAP D0 *SWAP THE HOLDER
00001BDE 86FC 000A 299 DIVU #$A,D3 *PERFORM CONVERSION DIVISION
00001BE2 3003 300 MOVE.W D3,D0 *MOVE MSW QUOTIENT TO D0
00001BE4 4840 301 SWAP D0 *SWAP IT INTO MSW POSITION
00001BE6 3600 302 MOVE.W D0,D3 *MOVE LSW INTO DIVIDEND
00001BE8 86FC 000A 303 DIVU #$A,D3 *PERFORM CONVERSION DIVISION
00001BEC 3003 304 MOVE.W D3,D0 *MOVE LSW QUOTIENT TO D0
00001BEE 4243 305 CLR.W D3 *CLEARS LSW QUOTIENT FROM D3
00001BF0 4843 306 SWAP D3 *SWAPS TOTAL REMAINDER TO LSW OF D3
00001BF2 4E75 307 RTS *RETURNS BIG QUOTIENT (D0), REMAINDER (D3)*
00001BF4 308 * Routines to control the Terminal Display
00001BF4 309 *
00001BF4 310 * By: Bradford W. Mott
00001BF4 311 *
00001BF4 312
00001BF4 313
00001BF4 =00000007 314 BELL_CODE: EQU 07
00001BF4 315
00001BF4 316
00001BF4 317 *
00001BF4 318 * This routine sounds the terminal bell
00001BF4 319 *
00001BF4 320
00001BF4 2F00 321 BELL: MOVE.L D0,-(A7) * Save D0 on stack
00001BF6 7007 322 MOVE.L #BELL_CODE,D0 * Get the BELL character
00001BF8 4EB8 14D0 323 JSR PUTC * Transmit it to the TERMINAL
00001BFC 201F 324 MOVE.L (A7)+,D0 * Restore D0
00001BFE 4E75 325 RTS * Return to calling procedure
00001C00 326
00001C00 327
00001C00 328 *
00001C00 329 * This routine clears the terminal display and homes the cursor
00001C00 330 *
00001C00 331
00001C00 48E7 8080 332 CLEAR: MOVEM.L D0/A0,-(A7) * Save A0&D0 on stack
00001C04 207C 00001C1C 333 MOVE.L #CLRSTR,A0 * Load address of clear screen string
00001C0A 1018 334 CLLOOP: MOVE.B (A0)+,D0 * Get a character
00001C0C 6700 0008 335 BEQ CLEXT * EXIT on NULL
00001C10 4EB8 14D0 336 JSR PUTC * Put character to display
00001C14 60F4 337 BRA CLLOOP * Loop
00001C16 4CDF 0101 338 CLEXT: MOVEM.L (A7)+,D0/A0 * Restore A0&D0
00001C1A 4E75 339 RTS * Return to calling procedure
00001C1C 340
00001C1C 1B 5B 3B 48 1B 5B 32 4A 00 00 341 CLRSTR: DC.B 27,'[;H',27,'[2J',0,0 * Clear Screen code for VT100
00001C26 342
00001C26 343
00001C26 344
00001C26 345 *
00001C26 346 * This routine moves the display's cursor to the X/Y coordinates
00001C26 347 * specified in the D0 & D1 registers (X=D0,Y=D1)
00001C26 348 *
00001C26 349
00001C26 48E7 FFFE 350 POSITION: MOVEM.L D0-D7/A0-A6,-(A7) * Save D0-D1 & A0 on stack
00001C2A 351
00001C2A 0280 000000FF 352 ANDI.L #255,D0 * Clear the unused parts of
00001C30 0281 000000FF 353 ANDI.L #255,D1 * data register
00001C36 354
00001C36 207C 00001CA4 355 MOVE.L #POSSTR+2,A0 * Address of row substring
00001C3C 82FC 000A 356 DIVU #10,D1 * Let's convert row number to ASCII
00001C40 0601 0030 357 ADDI.B #48,D1
00001C44 10C1 358 MOVE.B D1,(A0)+ * Put in POSSTR
00001C46 4841 359 SWAP D1
00001C48 0601 0030 360 ADDI.B #48,D1
00001C4C 1081 361 MOVE.B D1,(A0) * Put in POSSTR
00001C4E 362
00001C4E 13FC 0030 00001CA7 363 MOVE.B #48,POSSTR+5
00001C56 0C40 0064 364 CMPI.W #100,D0
00001C5A 6D00 000E 365 BLT POS2
00001C5E 366
00001C5E 0440 0064 367 SUBI.W #100,D0
00001C62 13FC 0031 00001CA7 368 MOVE.B #49,POSSTR+5
00001C6A 369
00001C6A 207C 00001CA8 370 POS2: MOVE.L #POSSTR+6,A0 * Address of col substring
00001C70 80FC 000A 371 DIVU #10,D0 * Let's convert column number to ASCII
00001C74 0600 0030 372 ADDI.B #48,D0
00001C78 10C0 373 MOVE.B D0,(A0)+ * Put in POSSTR
00001C7A 4840 374 SWAP D0
00001C7C 0600 0030 375 ADDI.B #48,D0
00001C80 1080 376 MOVE.B D0,(A0) * Put in POSSTR
00001C82 377
00001C82 207C 00001CA2 378 MOVE.L #POSSTR,A0 * Get addr of POSITION string
00001C88 1018 379 POSLOOP: MOVE.B (A0)+,D0 * Get a character
00001C8A 6700 0008 380 BEQ POSEXT * Exit on NULL
00001C8E 4EB8 14D0 381 JSR PUTC * Send to the terminal
00001C92 60F4 382 BRA POSLOOP * Loop
00001C94 383
00001C94 4CDF 7FFF 384 POSEXT: MOVEM.L (A7)+,D0-D7/A0-A6 * Restore registers
00001C98 4E75 385 RTS * Return to calling procedure
00001C9A 386
00001C9A 0000 0000 0000 0000 387 DC.W 0,0,0,0
00001CA2 1B 5B 30 30 3B 30 30 30 3B ... 388 POSSTR: DC.B 27,'[00;000;H',0 * Position Cursor code for VT100
00001CAE 0000 0000 0000 0000 389 DC.W 0,0,0,0
00001CB6 390
00001CB6 391
00001CB6 392
00001CB6 393
00001CB6 394
00001CB6 395 *
00001CB6 396 * This routine gets the sizes of the two matrices to multiply
00001CB6 397 *
00001CB6 398
00001CB6 48E7 FFFE 399 GETSIZE: MOVEM.L D0-D7/A0-A6,-(SP)
00001CBA 400
00001CBA 4EB8 1C00 401 JSR CLEAR
00001CBE 402
00001CBE 207C 00001E20 403 MOVE.L #GS_TIT,A0 Print title
00001CC4 4EB8 1502 404 JSR PRINT
00001CC8 405
00001CC8 406
00001CC8 207C 00001E7C 407 GS_GAC: MOVE.L #GS_CA,A0
00001CCE 4EB8 1502 408 JSR PRINT
00001CD2 409
00001CD2 227C 00001EDE 410 MOVE.L #GS_VALID,A1 Get number of columns
00001CD8 207C 00001EEA 411 MOVE.L #GS_BUFFER,A0
00001CDE 303C 0002 412 MOVE.W #2,D0
00001CE2 4EB8 1430 413 JSR INPUT
00001CE6 414
00001CE6 207C 00001EEA 415 MOVE.L #GS_BUFFER,A0
00001CEC 4EB8 1B7E 416 JSR ATOL
00001CF0 31C0 10D6 417 MOVE.W D0,MA_C
00001CF4 418
00001CF4 0C40 000A 419 CMPI.W #10,D0
00001CF8 6E00 000E 420 BGT GS_ACA
00001CFC 0C40 0001 421 CMPI.W #1,D0
00001D00 6D00 0006 422 BLT GS_ACA
00001D04 6000 0010 423 BRA GS_GAR
00001D08 424
00001D08 207C 00001EF0 425 GS_ACA: MOVE.L #GS_ERROR,A0
00001D0E 4EB8 1502 426 JSR PRINT
00001D12 4EF8 1CC8 427 JMP GS_GAC
00001D16 428
00001D16 429
00001D16 430
00001D16 207C 00001E94 431 GS_GAR: MOVE.L #GS_RA,A0
00001D1C 4EB8 1502 432 JSR PRINT
00001D20 433
00001D20 227C 00001EDE 434 MOVE.L #GS_VALID,A1 Get number of columns
00001D26 207C 00001EEA 435 MOVE.L #GS_BUFFER,A0
00001D2C 303C 0002 436 MOVE.W #2,D0
00001D30 4EB8 1430 437 JSR INPUT
00001D34 438
00001D34 207C 00001EEA 439 MOVE.L #GS_BUFFER,A0
00001D3A 4EB8 1B7E 440 JSR ATOL
00001D3E 31C0 10D4 441 MOVE.W D0,MA_R
00001D42 442
00001D42 0C40 000A 443 CMPI.W #10,D0
00001D46 6E00 000E 444 BGT GS_ARA
00001D4A 0C40 0001 445 CMPI.W #1,D0
00001D4E 6D00 0006 446 BLT GS_ARA
00001D52 6000 0010 447 BRA GS_GBC
00001D56 448
00001D56 207C 00001EF0 449 GS_ARA: MOVE.L #GS_ERROR,A0
00001D5C 4EB8 1502 450 JSR PRINT
00001D60 4EF8 1D16 451 JMP GS_GAR
00001D64 452
00001D64 453
00001D64 454
00001D64 207C 00001EAC 455 GS_GBC: MOVE.L #GS_CB,A0
00001D6A 4EB8 1502 456 JSR PRINT
00001D6E 457
00001D6E 227C 00001EDE 458 MOVE.L #GS_VALID,A1 Get number of columns
00001D74 207C 00001EEA 459 MOVE.L #GS_BUFFER,A0
00001D7A 303C 0002 460 MOVE.W #2,D0
00001D7E 4EB8 1430 461 JSR INPUT
00001D82 462
00001D82 207C 00001EEA 463 MOVE.L #GS_BUFFER,A0
00001D88 4EB8 1B7E 464 JSR ATOL
00001D8C 31C0 10DA 465 MOVE.W D0,MB_C
00001D90 466
00001D90 0C40 000A 467 CMPI.W #10,D0
00001D94 6E00 000E 468 BGT GS_BCA
00001D98 0C40 0001 469 CMPI.W #1,D0
00001D9C 6D00 0006 470 BLT GS_BCA
00001DA0 6000 0010 471 BRA GS_GBR
00001DA4 472
00001DA4 207C 00001EF0 473 GS_BCA: MOVE.L #GS_ERROR,A0
00001DAA 4EB8 1502 474 JSR PRINT
00001DAE 4EF8 1D64 475 JMP GS_GBC
00001DB2 476
00001DB2 477
00001DB2 478
00001DB2 207C 00001EC6 479 GS_GBR: MOVE.L #GS_RB,A0
00001DB8 4EB8 1502 480 JSR PRINT
00001DBC 481
00001DBC 227C 00001EDE 482 MOVE.L #GS_VALID,A1 Get number of columns
00001DC2 207C 00001EEA 483 MOVE.L #GS_BUFFER,A0
00001DC8 303C 0002 484 MOVE.W #2,D0
00001DCC 4EB8 1430 485 JSR INPUT
00001DD0 486
00001DD0 207C 00001EEA 487 MOVE.L #GS_BUFFER,A0
00001DD6 4EB8 1B7E 488 JSR ATOL
00001DDA 31C0 10D8 489 MOVE.W D0,MB_R
00001DDE 490
00001DDE 0C40 000A 491 CMPI.W #10,D0
00001DE2 6E00 000E 492 BGT GS_BRA
00001DE6 0C40 0001 493 CMPI.W #1,D0
00001DEA 6D00 0006 494 BLT GS_BRA
00001DEE 6000 0010 495 BRA GS_TEST
00001DF2 496
00001DF2 207C 00001EF0 497 GS_BRA: MOVE.L #GS_ERROR,A0
00001DF8 4EB8 1502 498 JSR PRINT
00001DFC 4EF8 1DB2 499 JMP GS_GBR
00001E00 500
00001E00 501
00001E00 3038 10D6 502 GS_TEST: MOVE.W MA_C,D0
00001E04 B078 10D8 503 CMP.W MB_R,D0
00001E08 6700 0010 504 BEQ GS_OK
00001E0C 505
00001E0C 207C 00001F02 506 MOVE.L #GS_BERR,A0
00001E12 4EB8 1502 507 JSR PRINT
00001E16 4EF8 1CC8 508 JMP GS_GAC
00001E1A 509
00001E1A 4CDF 7FFF 510 GS_OK: MOVEM.L (A7)+,D0-D7/A0-A6
00001E1E 4E75 511 RTS
00001E20 512
00001E20 513
00001E20 20 4D 61 74 72 69 78 20 4D ... 514 GS_TIT: DC.B ' Matrix Multiply ',10
00001E32 2D 2D 2D 2D 2D 2D 2D 2D 2D ... 515 DC.B '-----------------',10,10
00001E45 50 6C 65 61 73 65 20 65 6E ... 516 DC.B 'Please enter the sizes of the matrices to multiply.',10,10,0,0
00001E7C 517
00001E7C 0A 43 6F 6C 75 6D 6E 73 20 ... 518 GS_CA: DC.B 10,'Columns in matrix A : ',0
00001E94 0A 52 6F 77 73 20 69 6E 20 ... 519 GS_RA: DC.B 10,'Rows in matrix A : ',0
00001EAC 0A 0A 43 6F 6C 75 6D 6E 73 ... 520 GS_CB: DC.B 10,10,'Columns in matrix B : ',0,0
00001EC6 0A 52 6F 77 73 20 69 6E 20 ... 521 GS_RB: DC.B 10,'Rows in matrix B : ',0
00001EDE 522
00001EDE 30 31 32 33 34 35 36 37 38 ... 523 GS_VALID: DC.B '0123456789',0,0
00001EEA 00 00 00 00 00 00 524 GS_BUFFER: DC.B 0,0,0,0,0,0
00001EF0 525
00001EF0 0A 49 6E 76 61 6C 69 64 20 ... 526 GS_ERROR: DC.B 10,'Invalid size!!!',10,0
00001F02 0A 4D 61 74 72 69 78 20 73 ... 527 GS_BERR: DC.B 10,'Matrix sizes incompatible!!!!!',10,0,0
00001F24 528 *
00001F24 529 * This routine multiplies two matrices and stores the resulting
00001F24 530 * matrix. ( C=AB )
00001F24 531 *
00001F24 532 * A0 = Matrix A
00001F24 533 * A1 = Matrix B
00001F24 534 * A2 = Matrix C
00001F24 535 *
00001F24 536 * D0 = Matrix A number of rows (i)
00001F24 537 * D1 = Matrix A number of columns
00001F24 538 * D2 = Matrix B number of rows
00001F24 539 * D3 = Matrix B number of columns (j)
00001F24 540 *
00001F24 541
00001F24 542 MATMULT:
00001F24 48E7 FFFE 543 MOVEM.L D0-D7/A0-A6,-(A7)
00001F28 544
00001F28 33C3 00001FA0 545 MOVE.W D3,B_COLS Save Columns in C
00001F2E 546
00001F2E 3639 00001FA0 547 I_LOOP: MOVE.W B_COLS,D3
00001F34 5340 548 SUBI.W #1,D0
00001F36 6B00 005E 549 BMI MATFIN
00001F3A 550
00001F3A 23FC 00000000 00001F9C 551 J_LOOP: MOVE.L #0,SUM
00001F44 3801 552 MOVE.W D1,D4 T Counter
00001F46 5344 553 SUBI.W #1,D4
00001F48 554
00001F48 5343 555 SUB.W #1,D3
00001F4A 6BE2 556 BMI I_LOOP
00001F4C 557
00001F4C 3A01 558 T_LOOP: MOVE.W D1,D5 Num Columns in A
00001F4E CAC0 559 MULU D0,D5 I * Columns in A
00001F50 DA44 560 ADD.W D4,D5 + T
00001F52 CAFC 0002 561 MULU #2,D5 Words
00001F56 7C00 562 MOVEQ #0,D6
00001F58 3C30 5000 563 MOVE.W (A0,D5),D6 Get A(i,t)
00001F5C 564
00001F5C 3A39 00001FA0 565 MOVE.W B_COLS,D5 Num Columns in B
00001F62 CAC4 566 MULU D4,D5 T * Columns in B
00001F64 DA43 567 ADD.W D3,D5 + J
00001F66 CAFC 0002 568 MULU #2,D5
00001F6A 7E00 569 MOVEQ #0,D7
00001F6C 3E31 5000 570 MOVE.W (A1,D5),D7 Get B(t,j)
00001F70 571
00001F70 CFC6 572 MULS D6,D7 A(i,t)*B(t,j)
00001F72 DFB9 00001F9C 573 ADD.L D7,SUM add to running Sum
00001F78 574
00001F78 5344 575 SUBI.W #1,D4
00001F7A 6AD0 576 BPL T_LOOP
00001F7C 577
00001F7C 3A39 00001FA0 578 MOVE.W B_COLS,D5 Num Columns in C
00001F82 CAC0 579 MULU D0,D5 I * Num Columns in C
00001F84 DA43 580 ADD.W D3,D5 + J
00001F86 CAFC 0004 581 MULU #4,D5
00001F8A 25B9 00001F9C 5000 582 MOVE.L SUM,(A2,D5) Store C(i,j)
00001F92 583
00001F92 60A6 584 BRA J_LOOP
00001F94 6098 585 BRA I_LOOP
00001F96 586
00001F96 4CDF 7FFF 587 MATFIN: MOVEM.L (A7)+,D0-D7/A0-A6
00001F9A 4E75 588 RTS
00001F9C 589
00001F9C 590
00001F9C 00000001 591 SUM: DC.L $1
00001FA0 0001 592 B_COLS: DC.W $1
00001FA2 593 *
00001FA2 594 * MATOUT
00001FA2 595 **
00001FA2 596 * D0 contains the number of columns
00001FA2 597 * D1 contains the number of rows
00001FA2 598 *
00001FA2 599 * A0 contains a pointer to a buffer to store matrix elements in
00001FA2 600 * A1 contains a pointer to the a title string
00001FA2 601 *
00001FA2 602 * By: Bradford W. Mott
00001FA2 603 *
00001FA2 604
00001FA2 605
00001FA2 48E7 FFFE 606 MATOUT: MOVEM.L A0-A6/D0-D7,-(A7) Save registers on stack
00001FA6 607
00001FA6 23C8 00002196 608 MOVE.L A0,MO_DATA Store buffer address
00001FAC 33C0 0000219A 609 MOVE.W D0,MO_ROW Store num of rows
00001FB2 33C1 0000219C 610 MOVE.W D1,MO_COL Store num of columns
00001FB8 611
00001FB8 612
00001FB8 4EB8 1C00 613 JSR CLEAR Clear the display
00001FBC 614
00001FBC 207C 0000219E 615 MOVE.L #MO_32ON,A0 Turn 132 mode on
00001FC2 4EB8 1502 616 JSR PRINT
00001FC6 617
00001FC6 303C 0039 618 MOVE.W #57,D0 X position of cursor
00001FCA 323C 0002 619 MOVE.W #2,D1 Y position of cursor
00001FCE 4EB8 1C26 620 JSR POSITION Position the Cursor
00001FD2 621
00001FD2 2049 622 MOVE.L A1,A0 Print the Title String
00001FD4 4EB8 1502 623 JSR PRINT
00001FD8 624
00001FD8 625
00001FD8 207C 0000217E 626 MOVE.L #MO_Y,A0 Pointer to Y position array
00001FDE 7000 627 MOVEQ #0,D0 Clear LCV (Loop Control Var)
00001FE0 628
00001FE0 323C 0014 629 MO_L1: MOVE.W #20,D1 Calculate Y position
00001FE4 9279 0000219A 630 SUB.W MO_ROW,D1
00001FEA 82FC 0002 631 DIVU #2,D1
00001FEE D240 632 ADD.W D0,D1 (20-row)/2+counter
00001FF0 1181 0000 633 MOVE.B D1,0(A0,D0) Store in array
00001FF4 634
00001FF4 5240 635 ADDQ.W #1,D0
00001FF6 B079 0000219A 636 CMP.W MO_ROW,D0
00001FFC 66E2 637 BNE MO_L1
00001FFE 638
00001FFE 639
00001FFE 207C 0000218A 640 MOVE.L #MO_X,A0 Pointer to X position array
00002004 7000 641 MOVEQ #0,D0 Clear LCV (Loop Control Var)
00002006 642
00002006 323C 0084 643 MO_L2: MOVE.W #132,D1 Calculate X position
0000200A 3439 0000219C 644 MOVE.W MO_COL,D2
00002010 C4FC 000A 645 MULU #10,D2
00002014 9242 646 SUB.W D2,D1
00002016 82FC 0002 647 DIVU #2,D1
0000201A 3400 648 MOVE.W D0,D2
0000201C C4FC 000A 649 MULU #10,D2
00002020 D242 650 ADD.W D2,D1 (132-col*10)/2+counter*10
00002022 1181 0000 651 MOVE.B D1,0(A0,D0) Store in array
00002026 652
00002026 5240 653 ADDQ.W #1,D0
00002028 B079 0000219C 654 CMP.W MO_COL,D0
0000202E 66D6 655 BNE MO_L2
00002030 656
00002030 657
00002030 658 * Draw the Matrix outline
00002030 659
00002030 207C 0000217E 660 MOVE.L #MO_Y,A0 Pointer to Y position array
00002036 7E00 661 MOVEQ #0,D7 Clear LCV (Loop Control Var)
00002038 662
00002038 303C 0084 663 MO_L3: MOVE.W #132,D0 Calculate X position
0000203C 3239 0000219C 664 MOVE.W MO_COL,D1
00002042 C2FC 000A 665 MULU #10,D1
00002046 9041 666 SUB.W D1,D0
00002048 80FC 0002 667 DIVU #2,D0
0000204C 5540 668 SUBI.W #2,D0 D0=(132-col*10)/2-2
0000204E 669
0000204E 1230 7000 670 MOVE.B 0(A0,D7),D1 Get Y Position
00002052 671
00002052 4EB8 1C26 672 JSR POSITION Position Cursor
00002056 103C 007C 673 MOVE.B #$7C,D0 the "|" character
0000205A 4EB8 14D0 674 JSR PUTC
0000205E 675
0000205E 676
0000205E 303C 0084 677 MOVE.W #132,D0 Calculate X position
00002062 3239 0000219C 678 MOVE.W MO_COL,D1
00002068 C2FC 000A 679 MULU #10,D1
0000206C 9041 680 SUB.W D1,D0
0000206E 80FC 0002 681 DIVU #2,D0
00002072 D041 682 ADD.W D1,D0 D0=(132-col*10)/2+col*10
00002074 683
00002074 1230 7000 684 MOVE.B 0(A0,D7),D1 Get Y Position
00002078 685
00002078 4EB8 1C26 686 JSR POSITION Position Cursor
0000207C 103C 007C 687 MOVE.B #$7C,D0 the "|" character
00002080 4EB8 14D0 688 JSR PUTC
00002084 689
00002084 5247 690 ADDQ.W #1,D7
00002086 BE79 0000219A 691 CMP.W MO_ROW,D7
0000208C 66AA 692 BNE MO_L3
0000208E 693
0000208E 694 * Get the data for each element.
0000208E 695
0000208E 7E00 696 MOVEQ #0,D7 LCV for row
00002090 267C 0000218A 697 MOVE.L #MO_X,A3
00002096 287C 0000217E 698 MOVE.L #MO_Y,A4
0000209C 699
0000209C 7C00 700 MO_L4: MOVEQ #0,D6 LCV for column
0000209E 701
0000209E 1033 6000 702 MO_L5: MOVE.B 0(A3,D6),D0
000020A2 1234 7000 703 MOVE.B 0(A4,D7),D1
000020A6 4EB8 1C26 704 JSR POSITION
000020AA 705
000020AA 706
000020AA 23FC 20202020 0000213E 707 MOVE.L #$20202020,MO_OUT Set output to all spaces
000020B4 23FC 20202020 00002142 708 MOVE.L #$20202020,MO_OUT+4
000020BE 23FC 20200000 00002146 709 MOVE.L #$20200000,MO_OUT+8
000020C8 710
000020C8 2079 00002196 711 MOVE.L MO_DATA,A0
000020CE 3039 0000219C 712 MOVE.W MO_COL,D0
000020D4 C0C7 713 MULU D7,D0 D0=row*col
000020D6 C0FC 0004 714 MULU #4,D0 *4
000020DA 715
000020DA 3206 716 MOVE.W D6,D1
000020DC C2FC 0004 717 MULU #4,D1
000020E0 D041 718 ADD.W D1,D0
000020E2 719
000020E2 2230 0000 720 MOVE.L 0(A0,D0),D1 Store entry in Matrix Buffer
000020E6 721
000020E6 207C 00002148 722 MOVE.L #MO_OUT+10,A0
000020EC 4EB8 1B36 723 JSR LTOA
000020F0 724
000020F0 207C 0000213E 725 MOVE.L #MO_OUT,A0
000020F6 4EB8 1502 726 JSR PRINT
000020FA 727
000020FA 5246 728 ADDQ.W #1,D6
000020FC BC79 0000219C 729 CMP.W MO_COL,D6
00002102 669A 730 BNE MO_L5
00002104 731
00002104 5247 732 ADDQ.W #1,D7
00002106 BE79 0000219A 733 CMP.W MO_ROW,D7
0000210C 668E 734 BNE MO_L4
0000210E 735
0000210E 736
0000210E 737 * PRINT PROMPT
0000210E 303C 0000 738 MOVE.W #0,D0
00002112 323C 0016 739 MOVE.W #22,D1
00002116 4EB8 1C26 740 JSR POSITION
0000211A 207C 00002152 741 MOVE.L #MO_PROMPT,A0
00002120 4EB8 1502 742 JSR PRINT
00002124 743
00002124 4EB8 14F0 744 MO_LKEY: JSR GETC
00002128 0C00 000D 745 CMPI.B #13,D0
0000212C 66F6 746 BNE MO_LKEY
0000212E 747
0000212E 748 * Go back to 80 column mode
0000212E 207C 000021A4 749 MOVE.L #MO_32OFF,A0
00002134 4EB8 1502 750 JSR PRINT
00002138 751
00002138 752 * Return to calling routine
00002138 753
00002138 4CDF 7FFF 754 MOVEM.L (A7)+,A0-A6/D0-D7 Restore Registers
0000213C 755
0000213C 4E75 756 RTS Return to caller
0000213E 757
0000213E 758
0000213E 2D 31 30 30 30 00 00 00 00 ... 759 MO_OUT: DC.B '-1000',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
00002152 50 72 65 73 73 20 52 65 74 ... 760 MO_PROMPT: DC.B 'Press Return Key...',0
00002166 1B 5B 30 6D 00 00 761 MO_HOFF: DC.B 27,'[0m',0,0
0000216C 1B 5B 32 30 3B 32 33 72 00 00 762 MO_SSR: DC.B 27,'[20;23r',0,0
00002176 1B 5B 30 3B 32 34 72 00 763 MO_SRR: DC.B 27,'[0;24r',0
0000217E 00 00 00 00 00 00 00 00 00 ... 764 MO_Y: DC.B 0,0,0,0,0,0,0,0,0,0,0,0
0000218A 00 00 00 00 00 00 00 00 00 ... 765 MO_X: DC.B 0,0,0,0,0,0,0,0,0,0,0,0
00002196 00000000 766 MO_DATA: DC.L 0
0000219A 0000 767 MO_ROW: DC.W 0
0000219C 0000 768 MO_COL: DC.W 0
0000219E 1B 5B 3F 33 68 00 769 MO_32ON: DC.B 27,'[?3h',0
000021A4 1B 5B 3F 33 6C 00 770 MO_32OFF: DC.B 27,'[?3l',0
000021AA 771
000021AA 772
000021AA 773 *
000021AA 774 * MATIN
000021AA 775 *
000021AA 776 * This routine allows the user to enter the elements of a matrix
000021AA 777 *
000021AA 778 * D0 contains the number of columns
000021AA 779 * D1 contains the number of rows
000021AA 780 *
000021AA 781 * A0 contains a pointer to a buffer to store matrix elements in
000021AA 782 * A1 contains a pointer to the a title string
000021AA 783 *
000021AA 784 * By: Bradford W. Mott
000021AA 785 *
000021AA 786
000021AA 787
000021AA 48E7 FFFE 788 MATIN: MOVEM.L A0-A6/D0-D7,-(A7) Save registers on stack
000021AE 789
000021AE 23C8 00002460 790 MOVE.L A0,MI_DATA Store buffer address
000021B4 33C0 00002464 791 MOVE.W D0,MI_ROW Store num of rows
000021BA 33C1 00002466 792 MOVE.W D1,MI_COL Store num of columns
000021C0 793
000021C0 4EB8 1C00 794 JSR CLEAR Clear the display
000021C4 795
000021C4 303C 0021 796 MOVE.W #33,D0 X position of cursor
000021C8 323C 0002 797 MOVE.W #2,D1 Y position of cursor
000021CC 4EB8 1C26 798 JSR POSITION Position the Cursor
000021D0 799
000021D0 2049 800 MOVE.L A1,A0 Print the Title String
000021D2 4EB8 1502 801 JSR PRINT
000021D6 802
000021D6 803
000021D6 207C 00002447 804 MOVE.L #MI_Y,A0 Pointer to Y position array
000021DC 7000 805 MOVEQ #0,D0 Clear LCV (Loop Control Var)
000021DE 806
000021DE 323C 0014 807 MI_L1: MOVE.W #20,D1 Calculate Y position
000021E2 9279 00002464 808 SUB.W MI_ROW,D1
000021E8 82FC 0002 809 DIVU #2,D1
000021EC D240 810 ADD.W D0,D1 (20-row)/2+counter
000021EE 1181 0000 811 MOVE.B D1,0(A0,D0) Store in array
000021F2 812
000021F2 5240 813 ADDQ.W #1,D0
000021F4 B079 00002464 814 CMP.W MI_ROW,D0
000021FA 66E2 815 BNE MI_L1
000021FC 816
000021FC 817
000021FC 207C 00002453 818 MOVE.L #MI_X,A0 Pointer to X position array
00002202 7000 819 MOVEQ #0,D0 Clear LCV (Loop Control Var)
00002204 820
00002204 323C 0050 821 MI_L2: MOVE.W #80,D1 Calculate X position
00002208 3439 00002466 822 MOVE.W MI_COL,D2
0000220E C4FC 0006 823 MULU #6,D2
00002212 9242 824 SUB.W D2,D1
00002214 82FC 0002 825 DIVU #2,D1
00002218 3400 826 MOVE.W D0,D2
0000221A C4FC 0006 827 MULU #6,D2
0000221E D242 828 ADD.W D2,D1 (80-col*6)/2+counter*6
00002220 1181 0000 829 MOVE.B D1,0(A0,D0) Store in array
00002224 830
00002224 5240 831 ADDQ.W #1,D0
00002226 B079 00002466 832 CMP.W MI_COL,D0
0000222C 66D6 833 BNE MI_L2
0000222E 834
0000222E 835
0000222E 836 * Draw the Matrix outline
0000222E 837
0000222E 207C 00002447 838 MOVE.L #MI_Y,A0 Pointer to Y position array
00002234 7E00 839 MOVEQ #0,D7 Clear LCV (Loop Control Var)
00002236 840
00002236 303C 0050 841 MI_L3: MOVE.W #80,D0 Calculate X position
0000223A 3239 00002466 842 MOVE.W MI_COL,D1
00002240 C2FC 0006 843 MULU #6,D1
00002244 9041 844 SUB.W D1,D0
00002246 80FC 0002 845 DIVU #2,D0
0000224A 5540 846 SUBI.W #2,D0 D0=(80-col*6)/2-2
0000224C 847
0000224C 1230 7000 848 MOVE.B 0(A0,D7),D1 Get Y Position
00002250 849
00002250 4EB8 1C26 850 JSR POSITION Position Cursor
00002254 103C 007C 851 MOVE.B #$7C,D0 the "|" character
00002258 4EB8 14D0 852 JSR PUTC
0000225C 853
0000225C 854
0000225C 303C 0050 855 MOVE.W #80,D0 Calculate X position
00002260 3239 00002466 856 MOVE.W MI_COL,D1
00002266 C2FC 0006 857 MULU #6,D1
0000226A 9041 858 SUB.W D1,D0
0000226C 80FC 0002 859 DIVU #2,D0
00002270 D041 860 ADD.W D1,D0 D0=(80-col*6)/2+col*6
00002272 861
00002272 1230 7000 862 MOVE.B 0(A0,D7),D1 Get Y Position
00002276 863
00002276 4EB8 1C26 864 JSR POSITION Position Cursor
0000227A 103C 007C 865 MOVE.B #$7C,D0 the "|" character
0000227E 4EB8 14D0 866 JSR PUTC
00002282 867
00002282 5247 868 ADDQ.W #1,D7
00002284 BE79 00002464 869 CMP.W MI_ROW,D7
0000228A 66AA 870 BNE MI_L3
0000228C 871
0000228C 872
0000228C 873
0000228C 874 * Set the Display scrolling region
0000228C 875
0000228C 207C 00002435 876 MOVE.L #MI_SSR,A0 Addr of string
00002292 4EB8 1502 877 JSR PRINT
00002296 878
00002296 879
00002296 880 * Get the data for each element.
00002296 881
00002296 7E00 882 MOVEQ #0,D7 LCV for row
00002298 267C 00002453 883 MOVE.L #MI_X,A3
0000229E 287C 00002447 884 MOVE.L #MI_Y,A4
000022A4 885
000022A4 7C00 886 MI_L4: MOVEQ #0,D6 LCV for column
000022A6 887
000022A6 1033 6000 888 MI_L5: MOVE.B 0(A3,D6),D0
000022AA 1234 7000 889 MOVE.B 0(A4,D7),D1
000022AE 4EB8 1C26 890 JSR POSITION
000022B2 891
000022B2 207C 00002427 892 MOVE.L #MI_HON,A0 Turn Highlight on
000022B8 4EB8 1502 893 JSR PRINT
000022BC 894
000022BC 207C 00002420 895 MOVE.L #MI_SPACE,A0 Print Space
000022C2 4EB8 1502 896 JSR PRINT
000022C6 897
000022C6 207C 0000242F 898 MOVE.L #MI_HOFF,A0 Turn Highlight off
000022CC 4EB8 1502 899 JSR PRINT
000022D0 900
000022D0 303C 0000 901 MOVE.W #0,D0
000022D4 323C 0017 902 MOVE.W #23,D1
000022D8 4EB8 1C26 903 JSR POSITION
000022DC 904
000022DC 207C 000023F2 905 MI_AGAIN: MOVE.L #MI_PROMPT,A0 Print prompt
000022E2 4EB8 1502 906 JSR PRINT
000022E6 907
000022E6 207C 000023E4 908 MOVE.L #MI_INPUT,A0
000022EC 227C 000023D8 909 MOVE.L #MI_VALID,A1
000022F2 7005 910 MOVE.L #5,D0
000022F4 4EB8 1430 911 JSR INPUT INPUT the number
000022F8 912
000022F8 700A 913 MOVE.L #10,D0 NEWLINE
000022FA 4EB8 14D0 914 JSR PUTC
000022FE 915
000022FE 207C 000023E4 916 MOVE.L #MI_INPUT,A0
00002304 4EB8 1B7E 917 JSR ATOL Convert ASCII to Long INT
00002308 23C0 000023B6 918 MOVE.L D0,MI_INN
0000230E 919
0000230E 0C40 03E8 920 CMPI.W #1000,D0 Make sure number is right
00002312 6E00 000E 921 BGT MI_ER size
00002316 0C40 FC18 922 CMPI.W #-1000,D0
0000231A 6D00 0006 923 BLT MI_ER
0000231E 924
0000231E 6000 0010 925 BRA MI_NER
00002322 926
00002322 207C 00002402 927 MI_ER: MOVE.L #MI_ERROR,A0 Print Error Message
00002328 4EB8 1502 928 JSR PRINT
0000232C 4EF8 22DC 929 JMP MI_AGAIN Try Again!!!
00002330 930
00002330 23FC 20202020 000023CA 931 MI_NER: MOVE.L #$20202020,MI_OUT Set output to all spaces
0000233A 23FC 20000000 000023CE 932 MOVE.L #$20000000,MI_OUT+4
00002344 207C 000023D0 933 MOVE.L #MI_OUT+6,A0
0000234A 7200 934 MOVEQ #0,D1
0000234C 2239 000023B6 935 MOVE.L MI_INN,D1
00002352 4EB8 1B36 936 JSR LTOA
00002356 937
00002356 1033 6000 938 MOVE.B 0(A3,D6),D0
0000235A 1234 7000 939 MOVE.B 0(A4,D7),D1
0000235E 4EB8 1C26 940 JSR POSITION
00002362 941
00002362 207C 000023CA 942 MOVE.L #MI_OUT,A0 Print Entry
00002368 4EB8 1502 943 JSR PRINT
0000236C 944
0000236C 2079 00002460 945 MOVE.L MI_DATA,A0
00002372 3039 00002466 946 MOVE.W MI_COL,D0
00002378 C0C7 947 MULU D7,D0 D0=row*col
0000237A C0FC 0002 948 MULU #2,D0 *2
0000237E 949
0000237E 3206 950 MOVE.W D6,D1
00002380 C2FC 0002 951 MULU #2,D1
00002384 D041 952 ADD.W D1,D0
00002386 953
00002386 21B9 000023B8 0000 954 MOVE.L MI_INN+2,0(A0,D0) Store entry in Matrix Buffer
0000238E 955
0000238E 5246 956 ADDQ.W #1,D6
00002390 BC79 00002466 957 CMP.W MI_COL,D6
00002396 6600 FF0E 958 BNE MI_L5
0000239A 959
0000239A 5247 960 ADDQ.W #1,D7
0000239C BE79 00002464 961 CMP.W MI_ROW,D7
000023A2 6600 FF00 962 BNE MI_L4
000023A6 963
000023A6 964 * Reset the terminal's scrolling region
000023A6 965
000023A6 207C 0000243F 966 MOVE.L #MI_SRR,A0
000023AC 4EB8 1502 967 JSR PRINT
000023B0 968
000023B0 969
000023B0 970 * Return to calling routine
000023B0 971
000023B0 4CDF 7FFF 972 MOVEM.L (A7)+,A0-A6/D0-D7 Restore Registers
000023B4 973
000023B4 4E75 974 RTS Return to caller
000023B6 975
000023B6 976
000023B6 00000000 00000000 00000000 ... 977 MI_INN: DC.L 0,0,0,0,0
000023CA 2D 31 30 30 30 00 00 00 00 ... 978 MI_OUT: DC.B '-1000',0,0,0,0,0,0,0,0,0
000023D8 30 31 32 33 34 35 36 37 38 ... 979 MI_VALID: DC.B '0123456789-',0
000023E4 00 00 00 00 00 00 00 00 00 ... 980 MI_INPUT: DC.B 0,0,0,0,0,0,0,0,0,0,0,0,0,0
000023F2 45 6E 74 65 72 20 45 6C 65 ... 981 MI_PROMPT: DC.B 'Enter Element: ',0
00002402 2A 2A 2A 20 50 72 6F 62 6C ... 982 MI_ERROR: DC.B '*** Problem with entry!!!!',10,10,0,0
00002420 20 20 20 20 20 00 00 983 MI_SPACE: DC.B ' ',0,0
00002427 1B 5B 35 3B 37 6D 00 00 984 MI_HON: DC.B 27,'[5;7m',0,0
0000242F 1B 5B 30 6D 00 00 985 MI_HOFF: DC.B 27,'[0m',0,0
00002435 1B 5B 32 30 3B 32 33 72 00 00 986 MI_SSR: DC.B 27,'[20;23r',0,0
0000243F 1B 5B 30 3B 32 34 72 00 987 MI_SRR: DC.B 27,'[0;24r',0
00002447 00 00 00 00 00 00 00 00 00 ... 988 MI_Y: DC.B 0,0,0,0,0,0,0,0,0,0,0,0
00002453 00 00 00 00 00 00 00 00 00 ... 989 MI_X: DC.B 0,0,0,0,0,0,0,0,0,0,0,0
00002460 00000000 990 MI_DATA: DC.L 0
00002464 0000 991 MI_ROW: DC.W 0
00002466 0000 992 MI_COL: DC.W 0
00002468 993
00002468 994
00002468 207C 000024A8 995 EXIT: MOVE.L #QUITMSG,A0 *INITIALIZE QUIT PROMPT
0000246E 4EB8 1502 996 JSR PRINT *PRINT QUIT PROMPT
00002472 4EB8 14F0 997 JSR GETC *GET RESPONSE
00002476 B03C 0059 998 CMP.B #$59,D0 *A VALID CHARACTER?
0000247A 6700 001C 999 BEQ QSTRT *YES, START OVER
0000247E B03C 0079 1000 CMP.B #$79,D0 *A VALID CHARACTER?
00002482 6700 0014 1001 BEQ QSTRT *YES, START OVER
00002486 B03C 004E 1002 CMP.B #$4E,D0 *A VALID CHARACTER?
0000248A 6700 0010 1003 BEQ QFIN *NO, QUIT PROGRAM
0000248E B03C 006E 1004 CMP.B #$6E,D0 *A VALID CHARACTER?
00002492 6700 0008 1005 BEQ QFIN *NO, QUIT PROGRAM
00002496 60D0 1006 BRA EXIT *NOT A VALID CHARACTER
00002498 1007
00002498 6000 EB90 1008 QSTRT: BRA MAIN *RE-EXECUTE MAIN PROGRAM
0000249C 1009
0000249C 207C 000024CD 1010 QFIN: MOVE.L #ENDMSG,A0 *INITIALIZE FINAL MESSAGE
000024A2 4EB8 1502 1011 JSR PRINT *PRINT FINAL MESSAGE
000024A6 60FE 1012 NOMOE: BRA NOMOE *INFINITE LOOP
000024A8 1013
000024A8 0A 4D 75 6C 74 69 70 6C 79 ... 1014 QUITMSG: DC.B 10,'Multiply Another Set? <Y,y,N,n>...',0,0
000024CD 0A 0A 54 48 41 4E 4B 20 59 ... 1015 ENDMSG: DC.B 10,10,'THANK YOU, GOODBYE..',0
000024E4 1016
000024E4 1017
No errors detected
No warnings generated